package Dao;

import object.User;

public class UserDaoImpt implements UserDao{
    @Override
    public int AddUser(User user) {
        return useSQL.Add("users", "null", user.getUname(), user.getUpassword(),user.getUtype());
    }

    @Override
    public int DeleteUser(User user) {
        return 0;
    }

    @Override
    public int UpdateUser(User user) {
        if (user.getUpassword()==null&&user.getUname()!=null){
            return useSQL.Updeat("users", "uid", String.valueOf(user.getUid()),"uname",null,null,user.getUname(),null,null);
        }else if (user.getUname()==null&&user.getUpassword()!=null){
            return useSQL.Updeat("users", "uid", String.valueOf(user.getUid()),"upwd",null,null,user.getUpassword(),null,null);
        }else {
            return -3;
        }
    }

    @Override
    public boolean SelectUser(User user) {
        return useSQL.Select("users", "uname", user.getUname());
    }
}
